Github Actions Python Unit Test

您所在的位置:网站首页 github actions python Github Actions Python Unit Test

Github Actions Python Unit Test

#Github Actions Python Unit Test | 来源: 网络整理| 查看: 265

I have a python project with working code in a src module and unit tests in another module. When I run the unit test using Visual Studio code on my local workstation, the tests run fine. However, when I check the code into GitHib and use a GitHub action, the unit test cannot find the src directory with the needed modules. I have tried different configurations on the .yml file but nothing has worked so far.

Here is the .yml

jobs: on_build_actions: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt working-directory: src - name: Run Tests run: python -m unittest test_hypedsearch working-directory: test

Here is the error

Run python -m unittest test_hypedsearch E ====================================================================== ERROR: test_hypedsearch (unittest.loader._FailedTest) ---------------------------------------------------------------------- ImportError: Failed to import test module: test_hypedsearch Traceback (most recent call last): File "/usr/lib/python3.8/unittest/loader.py", line 154, in loadTestsFromName module = import(module_name) File "/home/runner/work/hypedsearch/hypedsearch/test/test_hypedsearch.py", line 5, in from src import runner, utils, database, objects ModuleNotFoundError: No module named 'src'

and here is the top of the unit test code that is throwing the error:

import sys, os.path import unittest src_path = (os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) + '/src/') sys.path.append(src_path) from src import runner, utils, database, objects

Do I need to add a different reference on github to point to the src folder? Here is the directory outline:

enter image description here



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3